package com.beaven.model.model.db;

import com.beaven.model.utils.DataUtil;
import com.raizlabs.android.dbflow.annotation.Column;
import com.raizlabs.android.dbflow.annotation.PrimaryKey;
import com.raizlabs.android.dbflow.annotation.Table;
import java.io.Serializable;
import java.util.Date;

/**
 * author: Beaven
 * time: 2017/5/24 9:33
 */
@Table(database = AppDatabase.class) public class Category extends BaseDbModel<Category>
    implements Serializable {

  @PrimaryKey private String id;

  // 分组名称
  @Column private String name;

  @Column private String ownerId;

  // 信息修改时间
  @Column private Date modifyAt;

  @Column private boolean isExpanded;

  public String getId() {
    return id;
  }

  public void setId(String id) {
    this.id = id;
  }

  public String getName() {
    return name;
  }

  public void setName(String name) {
    this.name = name;
  }

  public Date getModifyAt() {
    return modifyAt;
  }

  public String getOwnerId() {
    return ownerId;
  }

  public void setOwnerId(String ownerId) {
    this.ownerId = ownerId;
  }

  public void setModifyAt(Date modifyAt) {
    this.modifyAt = modifyAt;
  }

  public boolean isExpanded() {
    return isExpanded;
  }

  public void setExpanded(boolean expanded) {
    isExpanded = expanded;
  }

  @Override public boolean equals(Object o) {
    if (this == o) return true;
    if (o == null || getClass() != o.getClass()) return false;
    Category category = (Category) o;
    return DataUtil.equals(id, category.id)
        && DataUtil.equals(name, category.name)
        && DataUtil.equals(modifyAt, category.modifyAt)
        && DataUtil.equals(ownerId, category.ownerId);
  }

  @Override public int hashCode() {
    return id != null ? id.hashCode() : 0;
  }

  @Override public boolean isSame(Category old) {
    return DataUtil.equals(id, old.id);
  }

  @Override public boolean isUiContentSame(Category old) {
    return old == this || DataUtil.equals(name, old.name);
  }
}
